package org.omg.GIOP;

//
// Helper class for : Version
//
// @author OpenORB Compiler
//
public class VersionHelper {
	//
	// Insert Version into an any
	// @param a an any
	// @param t Version value
	//
	public static void insert(org.omg.CORBA.Any a, org.omg.GIOP.Version t) {
		a.insert_Streamable(new org.omg.GIOP.VersionHolder(t));
	}

	//
	// Extract Version from an any
	// @param a an any
	// @return the extracted Version value
	//
	public static org.omg.GIOP.Version extract(org.omg.CORBA.Any a) {
		return read(a.create_input_stream());
	}

	//
	// Internal TypeCode value
	//
	private static org.omg.CORBA.TypeCode _tc = null;
	private static boolean _working = false;

	//
	// Return the Version TypeCode
	// @return a TypeCode
	//
	public static org.omg.CORBA.TypeCode type() {
		if (_tc == null) {
			synchronized (org.omg.CORBA.TypeCode.class) {
				if (_tc != null)
					return _tc;
				if (_working)
					return org.omg.CORBA.ORB.init().create_recursive_tc(id());
				_working = true;
				org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
				org.omg.CORBA.StructMember[] _members = new org.omg.CORBA.StructMember[2];

				_members[0] = new org.omg.CORBA.StructMember();
				_members[0].name = "major";
				_members[0].type = orb
						.get_primitive_tc(org.omg.CORBA.TCKind.tk_octet);
				_members[1] = new org.omg.CORBA.StructMember();
				_members[1].name = "minor";
				_members[1].type = orb
						.get_primitive_tc(org.omg.CORBA.TCKind.tk_octet);
				_tc = orb.create_struct_tc(id(), "Version", _members);
				_working = false;
			}
		}
		return _tc;
	}

	//
	// Return the Version IDL ID
	// @return an ID
	//
	public static String id() {
		return _id;
	}

	private final static String _id = "IDL:omg.org/GIOP/Version:1.0";

	//
	// Read Version from a marshalled stream
	// @param istream the input stream
	// @return the readed Version value
	//
	public static org.omg.GIOP.Version read(
			org.omg.CORBA.portable.InputStream istream) {
		org.omg.GIOP.Version new_one = new org.omg.GIOP.Version();

		new_one.major = istream.read_octet();
		new_one.minor = istream.read_octet();

		return new_one;
	}

	//
	// Write Version into a marshalled stream
	// @param ostream the output stream
	// @param value Version value
	//
	public static void write(org.omg.CORBA.portable.OutputStream ostream,
			org.omg.GIOP.Version value) {
		ostream.write_octet(value.major);
		ostream.write_octet(value.minor);
	}

}
